
/**
 * _tpl(tplStr,data) 取自underscore
 */
(function () {
    var _isObject = function (obj) {
        var type = typeof obj;
        return type === 'function' || type === 'object' && !!obj;
    };
    var hasOwnProperty = Object.prototype.hasOwnProperty;
    var _has = function (obj, key) {
        return obj != null && hasOwnProperty.call(obj, key);
    };
    var nativeKeys = Object.keys;
    var _keys = function (obj) {
        if (!_isObject(obj)) return [];
        if (nativeKeys) return nativeKeys(obj);
        var keys = [];
        for (var key in obj) if (_has(obj, key)) keys.push(key);
        return keys;
    };
    var createEscaper = function (map) {
        var escaper = function (match) {
            return map[match];
        };
        // Regexes for identifying a key that needs to be escaped
        var source = '(?:' + _keys(map).join('|') + ')';
        var testRegexp = RegExp(source);
        var replaceRegexp = RegExp(source, 'g');
        return function (string) {
            string = string == null ? '' : '' + string;
            return testRegexp.test(string) ? string.replace(replaceRegexp, escaper) : string;
        };
    };
    var escapeMap = {
        '&': '&amp;',
        '<': '&lt;',
        '>': '&gt;',
        '"': '&quot;',
        "'": '&#x27;',
        '`': '&#x60;'
    };
    var escapes = {
        "'": "'",
        '\\': '\\',
        '\r': 'r',
        '\n': 'n',
        '\u2028': 'u2028',
        '\u2029': 'u2029'
    };
    var escaper = /\\|'|\r|\n|\u2028|\u2029/g;
    var escapeChar = function (match) {
        return '\\' + escapes[match];
    };
    window._template = function (text) {
        var settings = {
            evaluate: /\[\[([\s\S]+?)\]\]/g,
            interpolate: /{=([\s\S]+?)}/g,
            escape: /{-([\s\S]+?)}/g
        };
        var matcher = RegExp([
            settings.escape.source,
            settings.interpolate.source,
            settings.evaluate.source
        ].join('|') + '|$', 'g');
        var index = 0;
        var source = "__p+='";
        text.replace(matcher, function (match, escape, interpolate, evaluate, offset) {
            source += text.slice(index, offset).replace(escaper, escapeChar);
            index = offset + match.length;
            if (escape) {
                source += "'+\n((__t=(" + escape + "))==null?'':_escape(__t))+\n'";
            } else if (interpolate) {
                source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'";
            } else if (evaluate) {
                source += "';\n" + evaluate + "\n__p+='";
            }
            return match;
        });
        source += "';\n";
        source = 'with(obj||{}){\n' + source + '}\n';
        source = "var __t,__p='',__j=Array.prototype.join," +
            "print=function(){__p+=__j.call(arguments,'');};\n" +
            source + 'return __p;\n';
        try {
            var render = new Function('obj', '_escape', source);
        } catch (e) {
            e.source = source;
            throw e;
        }
        var template = function (data) {
            var _escape = createEscaper(escapeMap);
            return render.call(this, data, _escape);
        };
        template.source = 'function(obj){\n' + source + '}';
        return template;
    };
    window._tpl = function (tplStr, data) {
        return  _template(tplStr)(data);
    };
})();

var base64EncodeChars = new String("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");
var base64DecodeChars = new Array(-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
    52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
    15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
    41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1);
function request(paras) {
    var url = location.href;
    var paraString = url.substring(url.indexOf("?") + 1, url.length).split("&");
    var paraObj = {};
    for (var i = 0; j = paraString[i]; i++) {
        paraObj[j.substring(0, j.indexOf("=")).toLowerCase()] = j.substring(j.indexOf("=") + 1, j.length);
    }
    var returnValue = paraObj[paras.toLowerCase()];
    if (typeof(returnValue) == "undefined") {
        return "";
    } else {
        return returnValue;
    }
}
//必用库
/*! Lazy Load 1.9.7 - MIT license - Copyright 2010-2015 Mika Tuupola */
!function (a, b, c, d) {
    var e = a(b);
    a.fn.lazyload = function (f) {
        function g() {
            var b = 0;
            i.each(function () {
                var c = a(this);
                if (!j.skip_invisible || c.is(":visible"))if (a.abovethetop(this, j) || a.leftofbegin(this, j)); else if (a.belowthefold(this, j) || a.rightoffold(this, j)) {
                    if (++b > j.failure_limit)return!1
                } else c.trigger("appear"), b = 0
            })
        }

        var h, i = this, j = {threshold: 0, failure_limit: 0, event: "scroll", effect: "show", container: b, data_attribute: "original", skip_invisible: !1, appear: null, load: null, placeholder: ""};
        return f && (d !== f.failurelimit && (f.failure_limit = f.failurelimit, delete f.failurelimit), d !== f.effectspeed && (f.effect_speed = f.effectspeed, delete f.effectspeed), a.extend(j, f)), h = j.container === d || j.container === b ? e : a(j.container), 0 === j.event.indexOf("scroll") && h.bind(j.event, function () {
            return g()
        }), this.each(function () {
            var b = this, c = a(b);
            b.loaded = !1, (c.attr("src") === d || c.attr("src") === !1) && c.is("img") && c.attr("src", j.placeholder), c.one("appear", function () {
                if (!this.loaded) {
                    if (j.appear) {
                        var d = i.length;
                        j.appear.call(b, d, j)
                    }
                    a("<img />").bind("load", function () {
                        var d = c.attr("data-" + j.data_attribute);
                        c.hide(), c.is("img") ? c.attr("src", d) : c.css("background-image", "url('" + d + "')"), c[j.effect](j.effect_speed), b.loaded = !0;
                        var e = a.grep(i, function (a) {
                            return!a.loaded
                        });
                        if (i = a(e), j.load) {
                            var f = i.length;
                            j.load.call(b, f, j)
                        }
                    }).attr("src", c.attr("data-" + j.data_attribute))
                }
            }), 0 !== j.event.indexOf("scroll") && c.bind(j.event, function () {
                b.loaded || c.trigger("appear")
            })
        }), e.bind("resize", function () {
            g()
        }), /(?:iphone|ipod|ipad).*os 5/gi.test(navigator.appVersion) && e.bind("pageshow", function (b) {
            b.originalEvent && b.originalEvent.persisted && i.each(function () {
                a(this).trigger("appear")
            })
        }), a(c).ready(function () {
            g()
        }), this
    }, a.belowthefold = function (c, f) {
        var g;
        return g = f.container === d || f.container === b ? (b.innerHeight ? b.innerHeight : e.height()) + e.scrollTop() : a(f.container).offset().top + a(f.container).height(), g <= a(c).offset().top - f.threshold
    }, a.rightoffold = function (c, f) {
        var g;
        return g = f.container === d || f.container === b ? e.width() + e.scrollLeft() : a(f.container).offset().left + a(f.container).width(), g <= a(c).offset().left - f.threshold
    }, a.abovethetop = function (c, f) {
        var g;
        return g = f.container === d || f.container === b ? e.scrollTop() : a(f.container).offset().top, g >= a(c).offset().top + f.threshold + a(c).height()
    }, a.leftofbegin = function (c, f) {
        var g;
        return g = f.container === d || f.container === b ? e.scrollLeft() : a(f.container).offset().left, g >= a(c).offset().left + f.threshold + a(c).width()
    }, a.inviewport = function (b, c) {
        return!(a.rightoffold(b, c) || a.leftofbegin(b, c) || a.belowthefold(b, c) || a.abovethetop(b, c))
    }, a.extend(a.expr[":"], {"below-the-fold": function (b) {
        return a.belowthefold(b, {threshold: 0})
    }, "above-the-top": function (b) {
        return!a.belowthefold(b, {threshold: 0})
    }, "right-of-screen": function (b) {
        return a.rightoffold(b, {threshold: 0})
    }, "left-of-screen": function (b) {
        return!a.rightoffold(b, {threshold: 0})
    }, "in-viewport": function (b) {
        return a.inviewport(b, {threshold: 0})
    }, "above-the-fold": function (b) {
        return!a.belowthefold(b, {threshold: 0})
    }, "right-of-fold": function (b) {
        return a.rightoffold(b, {threshold: 0})
    }, "left-of-fold": function (b) {
        return!a.rightoffold(b, {threshold: 0})
    }})
}(jQuery, window, document);


/**
 * jQuery md5 $.md5("I'm Persian.");
 */
(function (e) {
    var m = function (p, o) {
        return(p << o) | (p >>> (32 - o))
    };
    var a = function (s, p) {
        var u, o, r, t, q;
        r = (s & 2147483648);
        t = (p & 2147483648);
        u = (s & 1073741824);
        o = (p & 1073741824);
        q = (s & 1073741823) + (p & 1073741823);
        if (u & o) {
            return(q ^ 2147483648 ^ r ^ t)
        }
        if (u | o) {
            if (q & 1073741824) {
                return(q ^ 3221225472 ^ r ^ t)
            } else {
                return(q ^ 1073741824 ^ r ^ t)
            }
        } else {
            return(q ^ r ^ t)
        }
    };
    var n = function (o, q, p) {
        return(o & q) | ((~o) & p)
    };
    var l = function (o, q, p) {
        return(o & p) | (q & (~p))
    };
    var j = function (o, q, p) {
        return(o ^ q ^ p)
    };
    var i = function (o, q, p) {
        return(q ^ (o | (~p)))
    };
    var g = function (q, p, v, u, o, r, t) {
        q = a(q, a(a(n(p, v, u), o), t));
        return a(m(q, r), p)
    };
    var c = function (q, p, v, u, o, r, t) {
        q = a(q, a(a(l(p, v, u), o), t));
        return a(m(q, r), p)
    };
    var h = function (q, p, v, u, o, r, t) {
        q = a(q, a(a(j(p, v, u), o), t));
        return a(m(q, r), p)
    };
    var d = function (q, p, v, u, o, r, t) {
        q = a(q, a(a(i(p, v, u), o), t));
        return a(m(q, r), p)
    };
    var f = function (r) {
        var v;
        var q = r.length;
        var p = q + 8;
        var u = (p - (p % 64)) / 64;
        var t = (u + 1) * 16;
        var w = Array(t - 1);
        var o = 0;
        var s = 0;
        while (s < q) {
            v = (s - (s % 4)) / 4;
            o = (s % 4) * 8;
            w[v] = (w[v] | (r.charCodeAt(s) << o));
            s++
        }
        v = (s - (s % 4)) / 4;
        o = (s % 4) * 8;
        w[v] = w[v] | (128 << o);
        w[t - 2] = q << 3;
        w[t - 1] = q >>> 29;
        return w
    };
    var b = function (r) {
        var q = "", o = "", s, p;
        for (p = 0; p <= 3; p++) {
            s = (r >>> (p * 8)) & 255;
            o = "0" + s.toString(16);
            q = q + o.substr(o.length - 2, 2)
        }
        return q
    };
    var k = function (p) {
        p = p.replace(/\x0d\x0a/g, "\x0a");
        var o = "";
        for (var r = 0; r < p.length; r++) {
            var q = p.charCodeAt(r);
            if (q < 128) {
                o += String.fromCharCode(q)
            } else {
                if ((q > 127) && (q < 2048)) {
                    o += String.fromCharCode((q >> 6) | 192);
                    o += String.fromCharCode((q & 63) | 128)
                } else {
                    o += String.fromCharCode((q >> 12) | 224);
                    o += String.fromCharCode(((q >> 6) & 63) | 128);
                    o += String.fromCharCode((q & 63) | 128)
                }
            }
        }
        return o
    };
    e.extend({md5: function (o) {
        var v = Array();
        var G, H, p, u, F, Q, P, N, K;
        var D = 7, B = 12, z = 17, w = 22;
        var O = 5, L = 9, J = 14, I = 20;
        var t = 4, s = 11, r = 16, q = 23;
        var E = 6, C = 10, A = 15, y = 21;
        o = k(o);
        v = f(o);
        Q = 1732584193;
        P = 4023233417;
        N = 2562383102;
        K = 271733878;
        for (G = 0; G < v.length; G += 16) {
            H = Q;
            p = P;
            u = N;
            F = K;
            Q = g(Q, P, N, K, v[G + 0], D, 3614090360);
            K = g(K, Q, P, N, v[G + 1], B, 3905402710);
            N = g(N, K, Q, P, v[G + 2], z, 606105819);
            P = g(P, N, K, Q, v[G + 3], w, 3250441966);
            Q = g(Q, P, N, K, v[G + 4], D, 4118548399);
            K = g(K, Q, P, N, v[G + 5], B, 1200080426);
            N = g(N, K, Q, P, v[G + 6], z, 2821735955);
            P = g(P, N, K, Q, v[G + 7], w, 4249261313);
            Q = g(Q, P, N, K, v[G + 8], D, 1770035416);
            K = g(K, Q, P, N, v[G + 9], B, 2336552879);
            N = g(N, K, Q, P, v[G + 10], z, 4294925233);
            P = g(P, N, K, Q, v[G + 11], w, 2304563134);
            Q = g(Q, P, N, K, v[G + 12], D, 1804603682);
            K = g(K, Q, P, N, v[G + 13], B, 4254626195);
            N = g(N, K, Q, P, v[G + 14], z, 2792965006);
            P = g(P, N, K, Q, v[G + 15], w, 1236535329);
            Q = c(Q, P, N, K, v[G + 1], O, 4129170786);
            K = c(K, Q, P, N, v[G + 6], L, 3225465664);
            N = c(N, K, Q, P, v[G + 11], J, 643717713);
            P = c(P, N, K, Q, v[G + 0], I, 3921069994);
            Q = c(Q, P, N, K, v[G + 5], O, 3593408605);
            K = c(K, Q, P, N, v[G + 10], L, 38016083);
            N = c(N, K, Q, P, v[G + 15], J, 3634488961);
            P = c(P, N, K, Q, v[G + 4], I, 3889429448);
            Q = c(Q, P, N, K, v[G + 9], O, 568446438);
            K = c(K, Q, P, N, v[G + 14], L, 3275163606);
            N = c(N, K, Q, P, v[G + 3], J, 4107603335);
            P = c(P, N, K, Q, v[G + 8], I, 1163531501);
            Q = c(Q, P, N, K, v[G + 13], O, 2850285829);
            K = c(K, Q, P, N, v[G + 2], L, 4243563512);
            N = c(N, K, Q, P, v[G + 7], J, 1735328473);
            P = c(P, N, K, Q, v[G + 12], I, 2368359562);
            Q = h(Q, P, N, K, v[G + 5], t, 4294588738);
            K = h(K, Q, P, N, v[G + 8], s, 2272392833);
            N = h(N, K, Q, P, v[G + 11], r, 1839030562);
            P = h(P, N, K, Q, v[G + 14], q, 4259657740);
            Q = h(Q, P, N, K, v[G + 1], t, 2763975236);
            K = h(K, Q, P, N, v[G + 4], s, 1272893353);
            N = h(N, K, Q, P, v[G + 7], r, 4139469664);
            P = h(P, N, K, Q, v[G + 10], q, 3200236656);
            Q = h(Q, P, N, K, v[G + 13], t, 681279174);
            K = h(K, Q, P, N, v[G + 0], s, 3936430074);
            N = h(N, K, Q, P, v[G + 3], r, 3572445317);
            P = h(P, N, K, Q, v[G + 6], q, 76029189);
            Q = h(Q, P, N, K, v[G + 9], t, 3654602809);
            K = h(K, Q, P, N, v[G + 12], s, 3873151461);
            N = h(N, K, Q, P, v[G + 15], r, 530742520);
            P = h(P, N, K, Q, v[G + 2], q, 3299628645);
            Q = d(Q, P, N, K, v[G + 0], E, 4096336452);
            K = d(K, Q, P, N, v[G + 7], C, 1126891415);
            N = d(N, K, Q, P, v[G + 14], A, 2878612391);
            P = d(P, N, K, Q, v[G + 5], y, 4237533241);
            Q = d(Q, P, N, K, v[G + 12], E, 1700485571);
            K = d(K, Q, P, N, v[G + 3], C, 2399980690);
            N = d(N, K, Q, P, v[G + 10], A, 4293915773);
            P = d(P, N, K, Q, v[G + 1], y, 2240044497);
            Q = d(Q, P, N, K, v[G + 8], E, 1873313359);
            K = d(K, Q, P, N, v[G + 15], C, 4264355552);
            N = d(N, K, Q, P, v[G + 6], A, 2734768916);
            P = d(P, N, K, Q, v[G + 13], y, 1309151649);
            Q = d(Q, P, N, K, v[G + 4], E, 4149444226);
            K = d(K, Q, P, N, v[G + 11], C, 3174756917);
            N = d(N, K, Q, P, v[G + 2], A, 718787259);
            P = d(P, N, K, Q, v[G + 9], y, 3951481745);
            Q = a(Q, H);
            P = a(P, p);
            N = a(N, u);
            K = a(K, F)
        }
        var M = b(Q) + b(P) + b(N) + b(K);
        return M.toLowerCase()
    }})
})(jQuery);
/**
 * jQuery JSON plugin v2.5.1 $.toJSON $.evalJSON
 */
(function ($) {
    var escape = /["\\\x00-\x1f\x7f-\x9f]/g, meta = {"\b": "\\b", "\t": "\\t", "\n": "\\n", "\f": "\\f", "\r": "\\r", '"': '\\"', "\\": "\\\\"}, hasOwn = Object.prototype.hasOwnProperty;
    $.toJSON = typeof JSON === "object" && JSON.stringify ? JSON.stringify : function (o) {
        if (o === null) {
            return"null"
        }
        var pairs, k, name, val, type = $.type(o);
        if (type === "undefined") {
            return undefined
        }
        if (type === "number" || type === "boolean") {
            return String(o)
        }
        if (type === "string") {
            return $.quoteString(o)
        }
        if (typeof o.toJSON === "function") {
            return $.toJSON(o.toJSON())
        }
        if (type === "date") {
            var month = o.getUTCMonth() + 1, day = o.getUTCDate(), year = o.getUTCFullYear(), hours = o.getUTCHours(), minutes = o.getUTCMinutes(), seconds = o.getUTCSeconds(), milli = o.getUTCMilliseconds();
            if (month < 10) {
                month = "0" + month
            }
            if (day < 10) {
                day = "0" + day
            }
            if (hours < 10) {
                hours = "0" + hours
            }
            if (minutes < 10) {
                minutes = "0" + minutes
            }
            if (seconds < 10) {
                seconds = "0" + seconds
            }
            if (milli < 100) {
                milli = "0" + milli
            }
            if (milli < 10) {
                milli = "0" + milli
            }
            return'"' + year + "-" + month + "-" + day + "T" + hours + ":" + minutes + ":" + seconds + "." + milli + 'Z"'
        }
        pairs = [];
        if ($.isArray(o)) {
            for (k = 0; k < o.length; k++) {
                pairs.push($.toJSON(o[k]) || "null")
            }
            return"[" + pairs.join(",") + "]"
        }
        if (typeof o === "object") {
            for (k in o) {
                if (hasOwn.call(o, k)) {
                    type = typeof k;
                    if (type === "number") {
                        name = '"' + k + '"'
                    } else {
                        if (type === "string") {
                            name = $.quoteString(k)
                        } else {
                            continue
                        }
                    }
                    type = typeof o[k];
                    if (type !== "function" && type !== "undefined") {
                        val = $.toJSON(o[k]);
                        pairs.push(name + ":" + val)
                    }
                }
            }
            return"{" + pairs.join(",") + "}"
        }
    };
    $.evalJSON = typeof JSON === "object" && JSON.parse ? JSON.parse : function (str) {
        return eval("(" + str + ")")
    };
    $.secureEvalJSON = typeof JSON === "object" && JSON.parse ? JSON.parse : function (str) {
        var filtered = str.replace(/\\["\\\/bfnrtu]/g, "@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, "]").replace(/(?:^|:|,)(?:\s*\[)+/g, "");
        if (/^[\],:{}\s]*$/.test(filtered)) {
            return eval("(" + str + ")")
        }
        throw new SyntaxError("Error parsing JSON, source is not valid.")
    };
    $.quoteString = function (str) {
        if (str.match(escape)) {
            return'"' + str.replace(escape, function (a) {
                var c = meta[a];
                if (typeof c === "string") {
                    return c
                }
                c = a.charCodeAt();
                return"\\u00" + Math.floor(c / 16).toString(16) + (c % 16).toString(16)
            }) + '"'
        }
        return'"' + str + '"'
    }
}(jQuery));

//uuid
/**
 * UUID.core.js: The minimal subset of the RFC-compliant UUID generator UUID.js.
 *
 * @fileOverview
 * @author  LiosK
 * @version core-1.0
 * @license The MIT License: Copyright (c) 2012 LiosK.
 */

/** @constructor */
function UUID() {
}

/**
 * The simplest function to get an UUID string.
 * @returns {string} A version 4 UUID string.
 */
UUID.generate = function () {
    var rand = UUID._gri, hex = UUID._ha;
    return  hex(rand(32), 8)          // time_low
        + "-"
        + hex(rand(16), 4)          // time_mid
        + "-"
        + hex(0x4000 | rand(12), 4) // time_hi_and_version
        + "-"
        + hex(0x8000 | rand(14), 4) // clock_seq_hi_and_reserved clock_seq_low
        + "-"
        + hex(rand(48), 12);        // node
};
UUID.create = function () {
    return UUID.generate().replaceAll("-", "");
};
/**
 * Returns an unsigned x-bit random integer.
 * @param {int} x A positive integer ranging from 0 to 53, inclusive.
 * @returns {int} An unsigned x-bit random integer (0 <= f(x) < 2^x).
 */
UUID._gri = function (x) { // _getRandomInt
    if (x < 0) return NaN;
    if (x <= 30) return (0 | Math.random() * (1 << x));
    if (x <= 53) return (0 | Math.random() * (1 << 30))
        + (0 | Math.random() * (1 << x - 30)) * (1 << 30);
    return NaN;
};

/**
 * Converts an integer to a zero-filled hexadecimal string.
 * @param {int} num
 * @param {int} length
 * @returns {string}
 */
UUID._ha = function (num, length) {  // _hexAligner
    var str = num.toString(16), i = length - str.length, z = "0";
    for (; i > 0; i >>>= 1, z += z) {
        if (i & 1) {
            str = z + str;
        }
    }
    return str;
};

//常用扩展
//String 扩展
(function () {
    String.prototype.trim = function () {
        var str = this;
        return str.replace(/(^[\s\u3000]*)|([\s\u3000]*$)/g, "");
    };
    String.prototype.format = function (args) {
        var result = this;
        if (arguments.length > 0) {

            if (arguments.length == 1 && typeof (args) == "object" && null != args) {
                for (var key in args) {
                    if (args[key] != undefined) {
                        if (null == args[key]) {
                            args[key] = ""
                        }
                        ;
                        var reg = new RegExp("({" + key + "})", "g");
                        result = result.replace(reg, args[key]);
                    }
                }
            } else {
                for (var i = 0; i < arguments.length; i++) {
                    if (arguments[i] != undefined) {
                        if (null == arguments[i]) {
                            arguments[i] = ""
                        }
                        ;
                        //var reg = new RegExp("({[" + i + "]})", "g");//这个在索引大于9时会有问题，谢谢何以笙箫的指出
                        var reg = new RegExp("({)" + i + "(})", "g");
                        result = result.replace(reg, arguments[i]);
                    }
                }
            }
        }
        return result;
    };
    String.prototype.joinStr = function (args) {
        var str = "";
        var split = this;
        for (var i = 0; i < arguments.length; i++) {
            var item = arguments[i];
            if (null != item) {
                item = item.toString().trim();
                if ("" != item) {
                    str += item + split;
                }
            }
        }
        str = str.substring(0, str.length - split.length);
        return str;
    };
    String.prototype.t = function () {
        var str = this;
        str = str.replace(/-/g, "/");
        return str;
    };
    String.prototype.endWith = function (str) {
        if (str == null || str == "" || this.length == 0 || str.length > this.length)
            return false;
        if (this.substring(this.length - str.length) == str)
            return true;
        else
            return false;
        return true;
    };
    String.prototype.startWith = function (str) {
        if (str == null || str == "" || this.length == 0 || str.length > this.length)
            return false;
        if (this.substr(0, str.length) == str)
            return true;
        else
            return false;
        return true;
    };
    String.prototype.replaceAll = function (s1, s2) {
        return this.replace(new RegExp(s1, "gm"), s2);
    };
    String.prototype.isNumber = function () {
        if (parseFloat(this).toString() == "NaN") {
            return false;
        } else {
            return true;
        }
        ;
    };
    String.prototype.isEmpty = function () {
        if (null == this) {
            return true;
        }
        if ("" == this) {
            return true;
        }
        return false;
    };
    String.prototype.isBlank = function () {
        if (null == this) {
            return true;
        }
        if ("" == this.trim()) {
            return true;
        }
        return false;
    };
    String.prototype.init = function () {
        if (null == this) {
            return null;
        }
        if ("" == this.trim()) {
            return null;
        }
        return this;
    };
})();
//Array 扩展
(function () {
  /*  Array.prototype.remove = function(dx)
    {
        if(isNaN(dx)||dx>this.length){return false;}
        this.splice(dx,1);
    }*/
    Array.prototype.remove=function(dx)
    {
        if(isNaN(dx)||dx>this.length){return false;}
        for(var i=0,n=0;i<this.length;i++)
        {
            if(this[i]!=this[dx])
            {
                this[n++]=this[i]
            }
        }
        this.length-=1
    }
})();

//Date 扩展
(function () {
    /** * 对Date的扩展，将 Date 转化为指定格式的String * 月(M)、日(d)、12小时(h)、24小时(H)、分(m)、秒(s)、周(E)、季度(q)
     可以用 1-2 个占位符 * 年(y)可以用 1-4 个占位符，毫秒(S)只能用 1 个占位符(是 1-3 位的数字) * eg: * (new
     Date()).pattern("yyyy-MM-dd hh:mm:ss.S")==> 2006-07-02 08:09:04.423
     * (new Date()).pattern("yyyy-MM-dd E HH:mm:ss") ==> 2009-03-10 二 20:09:04
     * (new Date()).pattern("yyyy-MM-dd EE hh:mm:ss") ==> 2009-03-10 周二 08:09:04
     * (new Date()).pattern("yyyy-MM-dd EEE hh:mm:ss") ==> 2009-03-10 星期二 08:09:04
     * (new Date()).pattern("yyyy-M-d h:m:s.S") ==> 2006-7-2 8:9:4.18
     */
    Date.prototype.format = function (fmt) {
        var o = {
            "M+": this.getMonth() + 1, //月份
            "d+": this.getDate(), //日
            "h+": this.getHours() % 12 == 0 ? 12 : this.getHours() % 12, //小时
            "H+": this.getHours(), //小时
            "m+": this.getMinutes(), //分
            "s+": this.getSeconds(), //秒
            "q+": Math.floor((this.getMonth() + 3) / 3), //季度
            "S": this.getMilliseconds() //毫秒
        };
        var week = {
            "0": "天",
            "1": "一",
            "2": "二",
            "3": "三",
            "4": "四",
            "5": "五",
            "6": "六"
        };
        if (/(y+)/.test(fmt)) {
            fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
        }
        if (/(E+)/.test(fmt)) {
            fmt = fmt.replace(RegExp.$1, ((RegExp.$1.length > 1) ? (RegExp.$1.length > 2 ? "星期" : "周") : "") + week[this.getDay() + ""]);
        }
        for (var k in o) {
            if (new RegExp("(" + k + ")").test(fmt)) {
                fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
            }
        }
        return fmt;
    };
    Date.prototype.toLocaleDate = function (mills) {
        var year = this.getFullYear();
        var month = this.getMonth() + 1;
        var day = this.getDate();
        var hour = this.getHours();
        var min = this.getMinutes();
        var seconds = this.getSeconds();
        if (month < 10) {
            month = "0" + month;
        }
        if (day < 10) {
            day = "0" + day;
        }
        if (hour < 10) {
            hour = "0" + hour;
        }
        if (min < 10) {
            min = "0" + min;
        }
        if (seconds < 10) {
            seconds = "0" + seconds;
        }

        return year + '-' + month + '-' + day + ' ' + hour + ':' + min + ':' + seconds;
    };
    Date.prototype.toShortDate = function () {
        var year = this.getFullYear();
        var month = this.getMonth() + 1;
        var day = this.getDate();
        if (month < 10) {
            month = "0" + month;
        }
        if (day < 10) {
            day = "0" + day;
        }
        return year + '-' + month + '-' + day;
    };

})();

//jquery  扩展
// Object和基础 扩展
(function ($) {
    $.Base = {
        init: function (obj) {
            if (typeof  obj == "undefined") {
                return null;
            }
            if (null == obj) {
                return null;
            }
            if (typeof  obj == "string") {
                if ("" == obj.trim()) {
                    return null;
                }
            }
            return obj;
        }
    };
    $.copy = function (myObj) {
        return $.evalJSON($.toJSON(myObj));
    };
    $.isHtml5 = function () {
        if (!('localStorage' in window && window['localStorage'] !== null)) {
            return false;
        }
        return true;
    };
    $.isUndefined = function (obj) {
        if (typeof  obj == "undefined") {
            return true;
        }
        return false;
    };
    $.toFloat = function (obj) {
        if (null == $.Base.init(obj)) {
            return parseFloat(0);
        }
        if (obj.isNumber()) {
            return parseFloat(obj);
        }
        return parseFloat(0);
    };
    $.regNS = function (s) {
        var arr = s.split('.');
        var namespace = window;
        for (var i = 0, k = arr.length; i < k; i++) {
            if (typeof namespace[arr[i].trim()] == 'undefined') {
                namespace[arr[i].trim()] = {};
            }
            namespace = namespace[arr[i].trim()];
        }
        return namespace;
    };
    $.getNS = function (s) {
        var arr = s.split('.');
        var namespace = window;
        for (var i = 0, k = arr.length; i < k; i++) {
            if (typeof namespace[arr[i].trim()] == 'undefined') {
                return undefined;
            }
            namespace = namespace[arr[i].trim()];
        }
        return namespace;
    };
    $.delNS = function (s) {
        var arr = s.split('.');
        var namespace = window;

        for (var i = 0, k = arr.length; i < k; i++) {
            if (typeof namespace[arr[i]] == 'undefined') {
                return;
            } else if (k == i + 1) {
                delete  namespace[arr[i]];
                return;
            } else {
                namespace = namespace[arr[i]];
            }
        }
    };
    $.fn.isSee = function () {
        if ($(window).scrollTop() > ($(this).offset().top + jQuery(this).outerHeight())
            || (($(window).scrollTop() + $(window).height()) < $(this).offset().top)) {
            return false;
        }
        return true;
    };
    $.fn.ko = function (fromData, toData, data) {
        if ($.isUndefined(data)) {
            data = {reload: false};
        }
        if ($.isUndefined(data.reload)) {
            data.reload = false;
        }
        if (!data.reload) {
            toData = ko.mapping.fromJS(fromData);
            ko.applyBindings(toData, this[0]);
        } else {
            ko.mapping.fromJS(fromData, toData);
        }
        return toData;
    };
    $.once2s = function (id, callback, time) {//2000ms内数据不可以相同
        var _time = 2000;
        if (!$.isUndefined(time)) {
            _time = time;
        }
        var md = $.md5(location.href + id);//当前页
        var json = sessionStorage.getItem(md);
        if (null == json) {
            json = 0;
            $.setItemS(md + "_begin", new Date().getTime());
        }
        $.setItemS(md, 1);
        var time = new Date().getTime()
            - new Date(parseInt(sessionStorage.getItem(md + "_begin"))).getTime();
        if (json == 0 || time > _time) {
            if (time > _time) {
                if (json != 0 && null == sessionStorage.getItem(md + "_v")) {
                    return;
                }
                $.setItemS(md + "_begin", new Date().getTime());
                sessionStorage.removeItem(md + "_v");
            }
            callback();
            $.setItemS(md + "_v", 1);
        }
    };
})(jQuery);
//
// $.getQueryString('myParam');
(function ($) {
    $.extend({
        getQueryString: function (name) {
            function parseParams() {
                var params = {},
                    e,
                    a = /\+/g,  // Regex for replacing addition symbol with a space
                    r = /([^&=]+)=?([^&]*)/g,
                    d = function (s) {
                        return decodeURIComponent(s.replace(a, " "));
                    },
                    q = window.location.search.substring(1);

                while (e = r.exec(q))
                    params[d(e[1])] = d(e[2]);

                return params;
            }

            if (!this.queryStringParams)
                this.queryStringParams = parseParams();

            return this.queryStringParams[name];
        }
    });
})(jQuery);


(function ($) {
    $.setItemS = function (key, value) {
        try {
            sessionStorage.setItem(key, value);
        } catch (ex) {
            console.dir(ex);
            //sessionStorage.clear();
            for (var i = sessionStorage.length - 1; i >= 0; i--) {
                var key = sessionStorage.key(i);
                console.dir(key);
                if (key.startWith("_zcache_")) {
                    sessionStorage.removeItem(key);
                }
            }
            sessionStorage.setItem(key, value);
        }
    };
    // string不用再序列化
    $.postz = function (url, param, callback) {
        var result = null;
        var md = "_zcache_" + $.md5(url + $.toJSON(param));
        var json = sessionStorage.getItem(md);
        if (null == json) {
            $.post(url, param, function (data) {
                if (typeof  data == "string") {
                    data = $.evalJSON(data);
                }
                $.setItemS(md, $.toJSON(data));
                data.reload = false;
                callback(data);
            });
        } else {
            result = $.evalJSON(json);
            result.reload = false;
            callback(result);
            var mdJson = $.md5(json);
            $.post(url, param, function (data) {
                var resultJsonStr = "";
                var resultData = null;
                if (typeof  data == "string") {
                    $.setItemS(md, data);
                    resultJsonStr = data;
                    resultData = $.evalJSON(data);
                } else {
                    var dataStr = $.toJSON(data);
                    $.setItemS(md, dataStr);
                    resultJsonStr = dataStr;
                    resultData = data;
                }
                if (mdJson != $.md5(resultJsonStr)) {
                    resultData.reload = true;
                    //callback(resultData);
                    // window.location.reload();
                }
            });
        }

    };
    $.postc = function (url, param, callback) {//2000ms内数据不可以相同
        var _time = 1000;
        var md = $.md5(url + $.toJSON(param));
        var json = sessionStorage.getItem(md);
        if (null == json) {
            json = 0;
            $.setItemS(md + "_begin", new Date().getTime());
        }
        $.setItemS(md, 1);
        var time = new Date().getTime()
            - new Date(parseInt(sessionStorage.getItem(md + "_begin"))).getTime();
        if (json == 0 || time > _time) {
            if (time > _time) {
                if (json != 0 && null == sessionStorage.getItem(md + "_v")) {
                    return;
                }
                $.setItemS(md + "_begin", new Date().getTime());
                sessionStorage.removeItem(md + "_v");
            }
            $.post(url, param, function (data) {
                callback(data);
                $.setItemS(md + "_v", 1);
            });
        }
    };
}(jQuery));


//必用库end
//历史库
(function (window,undefined) {
    /* Base64加密 */

    window.encrypt = function (str) {
        var returnVal, i, len;
        var c1, c2, c3;
        len = str.length;
        i = 0;
        returnVal = "";
        while (i < len) {
            c1 = str.charCodeAt(i++) & 0xff;
            if (i == len) {
                returnVal += base64EncodeChars.charAt(c1 >> 2);
                returnVal += base64EncodeChars.charAt((c1 & 0x3) << 4);
                break;
            }
            c2 = str.charCodeAt(i++);
            if (i == len) {
                returnVal += base64EncodeChars.charAt(c1 >> 2);
                returnVal += base64EncodeChars.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4));
                returnVal += base64EncodeChars.charAt((c2 & 0xF) << 2);
                break;
            }
            c3 = str.charCodeAt(i++);
            returnVal += base64EncodeChars.charAt(c1 >> 2);
            returnVal += base64EncodeChars.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4));
            returnVal += base64EncodeChars.charAt(((c2 & 0xF) << 2) | ((c3 & 0xC0) >> 6));
            returnVal += base64EncodeChars.charAt(c3 & 0x3F);
        }
        return returnVal;
    };
    /* Base64解密 */
    window.decrypt = function (str) {
        var c1, c2, c3, c4;
        var i, len, returnVal;
        len = str.length;
        i = 0;
        returnVal = "";
        while (i < len) {
            /*c1*/
            do {
                c1 = base64DecodeChars[str.charCodeAt(i++) & 0xff];
            } while (i < len && c1 == -1);
            if (c1 == -1)
                break;
            /*c2*/
            do {
                c2 = base64DecodeChars[str.charCodeAt(i++) & 0xff];
            } while (i < len && c2 == -1);
            if (c2 == -1)
                break;
            returnVal += String.fromCharCode((c1 << 2) | ((c2 & 0x30) >> 4));
            /*c3*/
            do {
                c3 = str.charCodeAt(i++) & 0xff;
                if (c3 == 61)
                    return returnVal;
                c3 = base64DecodeChars[c3];
            } while (i < len && c3 == -1);
            if (c3 == -1)
                break;
            returnVal += String.fromCharCode(((c2 & 0XF) << 4) | ((c3 & 0x3C) >> 2));
            /*c4*/
            do {
                c4 = str.charCodeAt(i++) & 0xff;
                if (c4 == 61)
                    return returnVal;
                c4 = base64DecodeChars[c4];
            } while (i < len && c4 == -1);
            if (c4 == -1)
                break;
            returnVal += String.fromCharCode(((c3 & 0x03) << 6) | c4);
        }
        return returnVal;
    };
// override
    window.requestEncryptUrl = function (paras) {
        var url = location.href;
        var encryptUrl = url.substring(url.indexOf("?") + 1, url.length);
        var decryptUrl = decrypt(encryptUrl).split("&");
        var paraObj = {};
        for (var i = 0; j = decryptUrl[i]; i++) {
            paraObj[j.substring(0, j.indexOf("=")).toLowerCase()] = j.substring(j.indexOf("=") + 1, j.length);
        }
        var returnValue = paraObj[paras.toLowerCase()];
        if (typeof(returnValue) == "undefined") {
            return "";
        } else {
            return returnValue;
        }
    };

// override
    window.getParameter= function(paras) {
        var url = document.location.href.split('&')[0];
        var length = url.length;
        if (url.indexOf("#") != -1) {
            length = url.indexOf("#")
        }
        var encryptUrl = url.substring(url.indexOf("?") + 1, length);
        var decryptUrl = decrypt(encryptUrl).split("&");
        var paraObj = {};
        for (var i = 0; j = decryptUrl[i]; i++) {
            paraObj[j.substring(0, j.indexOf("=")).toLowerCase()] = j.substring(j.indexOf("=") + 1, j.length);
        }
        var returnValue = paraObj[paras.toLowerCase()];
        if (typeof(returnValue) == "undefined") {
            return "";
        } else {
            return returnValue;
        }
    };

    window._getParam = function (param) {
        var value = requestEncryptUrl(param).trim();
        if ("" == value) {
            return null;
        }
        return value;
    };
    window.concatUrl =function (pageUrl, encryptParams) {
        var url = String(pageUrl).concat(encrypt(encryptParams));
        return url;
    };
    window._enUrl = function (pageUrl, paramObj) {
        var paramstr = String("");
        var and = "";
        var first = true;
        for (var p in paramObj) {
            if (first) {
                and = "";
            }
            var name = p;//属性名称
            var value = paramObj[p];//属性对应的值
            paramstr = paramstr.concat(and + name + "=" + value);
            first = false;
            and = "&";
        }
        return concatUrl(pageUrl + "?", paramstr);
    };
    window.checkCookie=function (cookieName) {
        var NameOfCookie = cookieName;
        var c = document.cookie.indexOf(NameOfCookie + "=");
        if (c != -1) {
            return true;
        }
        else {
        }
        return false;
    };
    window.setCookie=function (c_name, value, expiredays) {
        var exdate = new Date();
        exdate.setDate(exdate.getDate() + expiredays);
        document.cookie = c_name + "=" + escape(value) + ((expiredays == null) ? "" : ";expires=" + exdate.toGMTString() + ";path=/");
    };
    window.getCookie=function (c_name) {
        if (document.cookie.length > 0) { // 先查询cookie是否为空，为空就return
            c_start = document.cookie.indexOf(c_name + "=");// 通过String对象的indexOf()来检查这个cookie是否存在，不存在就为
            // -1
            if (c_start != -1) {
                c_start = c_start + c_name.length + 1;// 最后这个+1其实就是表示"="号啦，这样就获取到了cookie值的开始位置
                c_end = document.cookie.indexOf(";", c_start);// 其实我刚看见indexOf()第二个参数的时候猛然有点晕，后来想起来表示指定的开始索引的位置...这句是为了得到值的结束位置。因为需要考虑是否是最后一项，所以通过";"号是否存在来判断
                if (c_end == -1) {
                    c_end = document.cookie.length;
                }
                return unescape(document.cookie.substring(c_start, c_end));// 通过substring()得到了值。想了解unescape()得先知道escape()是做什么的，都是很重要的基础，想了解的可以搜索下，在文章结尾处也会进行讲解cookie编码细节
            }
        }
        return "";
    };
    window.isMobil=function isMobil(mobileNumber) {
        var reg = /^1\d{10}$/;
        if (!reg.exec(mobileNumber)) {
            return false;
        }
        return true;
    };
// 验证是否为数字
    window.isNumber= function isNumber(oNum) {
        if (!oNum) {
            return false;
        }
        var pattern = new RegExp("^\[1-9][0-9]*$");
        if (!(pattern.test(oNum))) {
            return false;
        }
        try {
            if (parseFloat(oNum) != oNum) {
                return false;
            }
        } catch (ex) {
            return false;
        }

        return true;
    };
    window.stripscript=function (s) {
        var pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~！@#￥……&*（）——|{}【】‘；：”“'。，、？]");
        var rs = "";
        for (var i = 0; i < s.length; i++) {
            rs = rs + s.substr(i, 1).replace(pattern, '');
        }
        return rs;
    };
    window._isBlank=function _isBlank(value) {
        if (value == null || typeof(value) == "undefined") {
            return  true;
        }
        value = value.toString();
        if (value.trim() == "") {
            return  true;
        }
        return false;
    };
    window._isNull=function (value) {
        if (null == value || typeof(value) == "undefined") {
            return true;
        }
        return false;
    };
    // 新的组件
    window._parseInt= function (obj) {
        if(null==obj){
            return null;
        }
        var result = parseInt(obj);
        if (isNaN(result)) {
            result = null;
        }
        return result;
    };
})(window);

_Base = {
    init: function (obj) {
        if (typeof  obj == "undefined") {
            return null;
        }
        if (null == obj) {
            return null;
        }
        if (typeof  obj == "string") {
            if ("" == obj.trim()) {
                return null;
            }
        }
        return obj;
    },
    str: function () {
        var str = "";
        for (var i = 0; i < arguments.length; i++) {
            str += arguments[i];
        }
        return str;
    },
    clone: function (myObj) {
        return $.evalJSON($.toJSON(myObj));
    },
    title: function (title) {
        $("#ban_title").html(title);
    },
    enterDown: function (inputId, btnId) {
        $(inputId).keydown(function (event) {
            if (event.keyCode == 13) {
                $(btnId).click();
                $(inputId).blur();
            }
        });
    },
    open: function (url) {
        var a = $("<a href='{0}' target='_blank'>Apple</a>".format(url)).get(0);
        var e = document.createEvent('MouseEvents');
        e.initEvent('click', true, true);
        a.dispatchEvent(e);
    },
    go: function (url) {
        window.location.href = url;
    },
    qr: function (url) {
        return "{0}/weixinAPI/getQrCodePic?url={1}".format(eventURL, url);
    },
    gotoId: function (id, num) {
        if ($(id).length == 0) {
            return;
        }
        var _targetTop = $(id).offset().top;//获取位置
        if (typeof num == "undefined") {
            num = 0;
        }
        _targetTop = _targetTop + num;
        jQuery("html,body").animate({scrollTop: _targetTop}, 100);//跳转
    },
    gotoName: function (name, num) {
        if ($("[name={0}]".format(name)).length == 0) {
            return;
        }
        var _targetTop = $("[name={0}]".format(name)).offset().top;//获取位置
        if (typeof num == "undefined") {
            num = 0;
        }
        _targetTop = _targetTop + num;
        jQuery("html,body").animate({scrollTop: _targetTop}, 100);//跳转
    },
    onerror: function (src) {
        var img = event.srcElement;
        img.src = src;
        img.onerror = null; //控制不要一直跳动
    },
    removeHTMLTag: function (str) {
        if (null == _Base.init(str)) {
            return "";
        }
        str = str.replace(/<\/?[^>]*>/g, ''); //去除HTML tag
        str = str.replace(/[ | ]*\n/g, '\n'); //去除行尾空白
        //str = str.replace(/\n[\s| | ]*\r/g,'\n'); //去除多余空行
        str = str.replace(/ /ig, '');//去掉
        return str;
    },
    evalJSON: function (data) {
        if (typeof  data == "string") {
            data = $.evalJSON(data);
        }
        return data;
    },
    result:function(data,success,fail){
        if("success"==data.status){
            if(typeof success=="undefined"){
                layer.info(data.msg);
            }else{
                success(data);
            }
        }
        if("fail"==data.status){
            if(typeof fail=="undefined"){
                layer.error(data.msg);
            }else{
                fail(data);
            }
        }
    },
    isSuccess: function (data) {
        if ("success" == data.status) {
            return true;
        }
        return false;
    },
    isError: function (data) {
        if ("error" == data.status) {
            return true;
        }
        return false;
    }
};
var _URL={
    toShortURL:function(url,cal){
        $.ajax({
            'url' : eventURL+"util/shortURL.do",
            'type' : 'POST',
            'data' : {url:url},
            'async' : true,
            'dataType' : 'json',
            'success' : function(data) {
                cal(data);
            }
        });
    }
};
var _IDNumber = {
    getData: function (idCard) {
        var IDBean = {};
        var birthday = "";
        if (idCard != null && idCard != "") {
            if (idCard.length == 15) {
                birthday = "19" + idCard.substr(6, 6);
            } else if (idCard.length == 18) {
                birthday = idCard.substr(6, 8);
            }

            birthday = birthday.replace(/(.{4})(.{2})/, "$1-$2-");
        }
        IDBean.birthDay = birthday;
        return IDBean;
    }
};
var _Date = {

    toDeadLine: function (deadline) {
        var str = "";
        var startDate = new Date();
        var month = this.getDateMonthSub(startDate.getTime(), deadline);
        if (month > 0) {
            str += _NoToChinese(month) + "个月";
            startDate = this.DateAdd("m", month, startDate);
        }
        var day = this.getDateDaySub(startDate.getTime(), deadline);
        if (day > 0) {
            var dayStr = _NoToChinese(day);
            str += dayStr + "天";
            startDate = this.DateAdd("d", day, startDate);
        }
        var hour = this.getDateHourSub(startDate.getTime(), deadline);
        if (hour > 0 && day == 0) {
            str += _NoToChinese(hour) + "个小时";
        }
        return str;
    },
    getDateDaySub: function (startDate, endDate) {
        if (startDate == null || startDate == undefined || startDate == ""
            || endDate == null || endDate == undefined || endDate == "")
            return 0;
        var endDate = new Date(endDate);
        var startDate = new Date(startDate);
        var day = (endDate.getTime() - startDate.getTime()) / (1000 * 60 * 60 * 24);
        return parseInt(day);
    },
    getDateHourSub: function (startDate, endDate) {
        if (startDate == null || startDate == undefined || startDate == ""
            || endDate == null || endDate == undefined || endDate == "")
            return 0;
        var endDate = new Date(endDate);
        var startDate = new Date(startDate);
        var hour = (endDate.getTime() - startDate.getTime()) / (1000 * 60 * 60);
        return parseInt(hour);
    },
    getDateHourSub: function (startDate, endDate) {
        if (startDate == null || startDate == undefined || startDate == ""
            || endDate == null || endDate == undefined || endDate == "")
            return 0;
        var endDate = new Date(endDate);
        var startDate = new Date(startDate);
        var hour = (endDate.getTime() - startDate.getTime()) / (1000 * 60 * 60);
        return parseInt(hour);
    },
    /**
     **判断是否为当年当月的最后一天
     */
    isLastDay: function (yearV, monthV, dayV) {
        var new_year = yearV; //取当前的年份
        var new_month = monthV + 1;//取下一个月的第一天，方便计算（最后一天不固定）
        if (new_month > 12) //如果当前大于12月，则年份转到下一年
        {
            new_month -= 12; //月份减
            new_year++; //年份增
        }
        var new_date = new Date(new_year, new_month, 1); //取当年当月中的第一天
        var lastDay = (new Date(new_date.getTime() - 1000 * 60 * 60 * 24)).getDate();//获取当月最后一天日期
        if (lastDay == dayV) {
            return true;
        } else {
            return false;
        }
    },
    /**
     **计算距离月底还有几天
     */
    getLastDayAway: function (yearV, monthV, dayV) {
        var new_year = yearV; //取当前的年份
        var new_month = monthV + 1;//取下一个月的第一天，方便计算（最后一天不固定）
        if (new_month > 12) //如果当前大于12月，则年份转到下一年
        {
            new_month -= 12; //月份减
            new_year++; //年份增
        }
        var new_date = new Date(new_year, new_month, 1); //取当年当月中的第一天
        var lastDay = (new Date(new_date.getTime() - 1000 * 60 * 60 * 24)).getDate();//获取当月最后一天日期
        var away_day = lastDay - dayV;
        return away_day;
    },
    /**
     * @param startDate
     * 开始日期
     * @param endDate
     * 结束日期
     * @return 计算相差月份，必须满足正好一个月才进一
     */
    getDateMonthSub: function (startDate, endDate) {
        if (startDate == null || startDate == undefined || startDate == ""
            || endDate == null || endDate == undefined || endDate == "")
            return 0;
        var endDate = new Date(endDate);
        var startDate = new Date(startDate);
        var renNumber = 0;
        var yearToMonth = (endDate.getFullYear() - startDate.getFullYear()) * 12;
// 计算年份相差月份
        renNumber += yearToMonth;
        var startYear = startDate.getFullYear();// 开始日期-年份
        var endYear = endDate.getFullYear();// 结束日期-年份
        var startMon = startDate.getMonth();// 开始日期-月份
        var endMon = endDate.getMonth();// 结束日期-月份
        var startDay = startDate.getDate();// 开始日期-日
        var endDay = endDate.getDate();// 开始日期-日
        var monthToMonth = endDate.getMonth() - startDate.getMonth();
// 计算月份相差
        renNumber += monthToMonth;
// 如果开始日期是最后一天并且结束日期不是最后一天，那么返回值-1
        if (this.isLastDay(startYear, startMon, startDay)
            && !this.isLastDay(endYear, endMon, endDay)) {
            renNumber -= 1;
            return renNumber;
        } else {
// 如果开始日期和结束日期都不是最后一天
            if (!this.isLastDay(startYear, startMon, startDay)
                && !this.isLastDay(endYear, endMon, endDay)) {
// 如果都不是最后一天，就需要计算开始日期和结束日期的天数距离结束还有几天,分别为start_last,end_last
                var start_last = this.getLastDayAway(startYear, startMon, startDay);
                var end_last = this.getLastDayAway(endYear, endMon, endDay);

// 如果结束日期距离月底的天数比开始日期距离月底的天数大，则返回值-1
                if (end_last > start_last) {
                    renNumber -= 1;
                    return renNumber;
                } else {
                    return renNumber;
                }
            } else {
// 如果开始日期和结束日期的天都是当月的最后一天，那么相差月份就是实际月份相减的值
// 其他情况都直接返回renNumber
                return renNumber;
            }
        }
    },

//创建实例
    DateAdd: function (interval, number, date) {
        /*
         *   功能:实现VBScript的DateAdd功能.
         *   参数:interval,字符串表达式，表示要添加的时间间隔.
         *   参数:number,数值表达式，表示要添加的时间间隔的个数.
         *   参数:date,时间对象.
         *   返回:新的时间对象.
         *   var   now   =   new   Date();
         *   var   newDate   =   DateAdd( "d ",5,now);
         *---------------   DateAdd(interval,number,date)   -----------------
         */
        switch (interval) {
            case   "y"   :
            {
                date.setFullYear(date.getFullYear() + number);
                return   date;
                break;
            }
            case   "q"   :
            {
                date.setMonth(date.getMonth() + number * 3);
                return   date;
                break;
            }
            case   "m"   :
            {
                date.setMonth(date.getMonth() + number);
                return   date;
                break;
            }
            case   "w"   :
            {
                date.setDate(date.getDate() + number * 7);
                return   date;
                break;
            }
            case   "d"   :
            {
                date.setDate(date.getDate() + number);
                return   date;
                break;
            }
            case   "h"   :
            {
                date.setHours(date.getHours() + number);
                return   date;
                break;
            }
            case   "m"   :
            {
                date.setMinutes(date.getMinutes() + number);
                return   date;
                break;
            }
            case   "s"   :
            {
                date.setSeconds(date.getSeconds() + number);
                return   date;
                break;
            }
            default   :
            {
                date.setDate(d.getDate() + number);
                return   date;
                break;
            }
        }
    }


};
var _NoToChinese = function (num) {
    return num;
    if (!/^\d*(\.\d*)?$/.test(num)) {
        alert("Number is wrong!");
        return "Number is wrong!";
    }
    var AA = new Array("零", "一", "二", "三", "四", "五", "六", "七", "八", "九");
    var BB = new Array("", "十", "百", "千", "万", "亿", "点", "");
    var a = ("" + num).replace(/(^0*)/g, "").split("."), k = 0, re = "";
    for (var i = a[0].length - 1; i >= 0; i--) {
        switch (k) {
            case 0:
                re = BB[7] + re;
                break;
            case 4:
                if (!new RegExp("0{4}\\d{" + (a[0].length - i - 1) + "}$").test(a[0]))
                    re = BB[4] + re;
                break;
            case 8:
                re = BB[5] + re;
                BB[7] = BB[5];
                k = 0;
                break;
        }
        if (k % 4 == 2 && a[0].charAt(i + 2) != 0 && a[0].charAt(i + 1) == 0) re = AA[0] + re;
        if (a[0].charAt(i) != 0) re = AA[a[0].charAt(i)] + BB[k % 4] + re;
        k++;
    }

    if (a.length > 1) //加上小数部分(如果有小数部分)
    {
        re += BB[6];
        for (var i = 0; i < a[1].length; i++) re += AA[a[1].charAt(i)];
    }
    if (re.length > 1) {
        if ("一" == re.charAt(0)) {
            re = re.substring(1);
        }
    }
    return re;
};
var Msg = {
    setMsg: function (key, value) {
        sessionStorage.setItem(key, value);
    },
    setLoginBackUrl: function () {
        Msg.setMsg("loginBackURL", window.location.href);
    },
    showMsg: function (key, callback) {
        var info = sessionStorage.getItem(key);
        if (null != info) {
            sessionStorage.removeItem(key);
        }
        var url = location.href;
        if (url.indexOf("pc/") != -1 && url.indexOf("wx/views") != -1) {
            info = null;
        }
        if (url.indexOf("wx/views") != -1 && url.indexOf("pc/") != -1) {
            info = null;
        }
        callback(info);
    },
    setError: function (message) {
        sessionStorage.setItem("error", message);
    },
    showError: function () {
        var error = sessionStorage.getItem("error");
        if (null != error) {
            layer.error(error);
            sessionStorage.removeItem("error");
        }

    },
    setInfo: function (message) {
        sessionStorage.setItem("info", message);
    },
    showInfo: function () {
        var info = sessionStorage.getItem("info");
        if (null != info) {
            layer.info(info);
            sessionStorage.removeItem("info");
        }
    }
};
var ImageDo = {
    extStr: function (data) {
        if (!_isBlank(data.w) && !_isBlank(data.h)) {
            return "_" + data.w + "_" + data.h;
        }
        if (!_isBlank(data.s)) {
            var s = data.s.replaceAll("\\.", "__");
            return "_" + s;
        }
        return "";
    },
    extWenStr: function (data) {
        if (!_isBlank(data.w) && !_isBlank(data.h)) {
            return "w=" + data.w + "&h=" + data.h;
        }
        if (!_isBlank(data.s)) {
            return "s=" + s;
        }
        return "";
    },
    defaultImg: function (defaultUrl) {
        if (null == defaultUrl || 'null' == defaultUrl) {
            return null;
        }
        var img = event.srcElement;
        img.src = defaultUrl;
        img.onerror = null;
    },
    error: function (errorUrl, defaultUrl) {
        var img = event.srcElement;
        img.src = errorUrl;

        if (typeof defaultUrl == "undefined" || 'null' == defaultUrl) {
            defaultUrl = null;
            img.onerror = null;
        } else {
            img.onerror = ImageDo.defaultImg(defaultUrl);
        }
    },
    init: function (imageUrlOrg, defaultImg) {
        var imageUrl = defaultImg;
        if (!_isBlank(imageUrlOrg)) {
            if (imageUrlOrg.indexOf("http") > -1) {
                imageUrl = imageUrlOrg;
            } else {
                imageUrl = nginxURL + imageUrlOrg;
            }

        }
        return imageUrl;
    },
    initw: function (imageUrlOrg, defaultImg) {
        var imageUrl = defaultImg;
        if (!_isBlank(imageUrlOrg)) {
            imageUrl = nginxURL + imageUrlOrg;
        }
        return imageUrl;
    },
    filter: function (id, data, defaultImg) {
        var imgs = $(id).find("img");
        if (imgs.length == 0) {
            imgs = $(id).filter("img");
        }
        if (imgs.length == 0) {
            return;
        }
        if (typeof defaultImg == "undefined") {
            defaultImg = null;
        }

        imgs.each(function (index, elem) {
            var imgStr = $(elem).attr("img-src");
            if (!_isBlank(imgStr)) {
                if (imgStr.indexOf("?") != -1) {
                    imgStr = imgStr.substring(0, imgStr.indexOf("?"))
                }
                var imgFolder = imgStr.substring(0, imgStr.lastIndexOf("/") + 1);
                var imgFullName = imgStr.substring(imgStr.lastIndexOf("/") + 1);
                var imgName = imgFullName.substring(0, imgFullName.indexOf("\."));
                var imgExt = imgFullName.substring(imgFullName.indexOf("\."));
                if (imgStr.indexOf("/files/") != -1) {
                    var errorUrl = geexekEnrollURL + imgStr.substring(imgStr.indexOf("/files/") + 1);
                    imgStr = imgFolder + imgName + ImageDo.extStr(data) + imgExt;
                    errorUrl = errorUrl + "?" + ImageDo.extWenStr(data);
                    $(elem).attr("onerror", "ImageDo.error('" + errorUrl + "','" + defaultImg + "');");
                    // console.dir(imgStr);
                } else {
                    imgStr = imgStr + "?" + ImageDo.extWenStr(data);
                }
                elem.src = imgStr;
                $(elem).removeAttr("img-src");
            }


        });
    }
};
var permission = {
    isWeiXin: function () {
        var ua = window.navigator.userAgent.toLowerCase();
        if (ua.match(/MicroMessenger/i) == 'micromessenger') {
            return true;
        } else {
            return false;
        }
    },
    checkUser: function (nouser, haveuser) {
        if ("" == _userId) {
            nouser();
        } else {
            haveuser();
        }
    },
    mobileCheck: function (data) {
        if (typeof  data == "string") {
            data = $.evalJSON(data);
        }
        if (typeof data.authorize != "undefined") {
            if (-1 == data.authorize) {
                if (permission.isWeiXin()) {
                    window.location.reload();
                    return false;
                } else {
                    Msg.setInfo("请先登录!");
                    Msg.setMsg("loginBackURL", window.location.href);
                    window.location.href = raceURL + "wx/views/wx_login.html";
                    return false;
                }
                return false;
            }
        }
        return true;
    },
    mobileCheckUser: function () {
        if ("" == _userId) {
            Msg.setInfo("请先登录!");
            Msg.setMsg("loginBackURL", window.location.href);
            window.location.href = raceURL + "wx/views/wx_login.html";
            return false;
        }
        return true;
    },
    wxCheck: function (data) {
        if (typeof  data == "string") {
            data = $.evalJSON(data);
        }
        if (typeof data.authorize != "undefined") {
            if (-1 == data.authorize) {
                window.location.reload();
                return false;
            }
        }
        return true;
    },
    pcCheckUser: function () {
        if ("" == _userId) {
            Msg.setInfo("请先登录!");
            Msg.setMsg("loginBackURL", window.location.href);
            window.location.href = raceURL + "pc/login/login.html";
            return false;
        }
        return true;
    },

    pcCheck: function (data) {
        if (typeof  data == "string") {
            data = $.evalJSON(data);
        }
        if (typeof data.authorize != "undefined") {
            if (-1 == data.authorize) {
                Msg.setInfo("请先登录!");
                Msg.setMsg("loginBackURL", window.location.href);
                window.location.href = raceURL + "pc/login/login.html";
                return false;
            }
        }
        return true;
    }
};
var _share = {
    wx: function (link, desc, title, imgUrl, hide) {
        var share = {'localLink': document.location.href,
            'link': link, 'desc': desc, 'imgUrl': title, 'title': imgUrl, hide: hide};
        initWeiXinConfig(share);
    },
    wxCmpt: function (cmptId, cmptName, imgUrl) {
        this.wx(concatUrl(raceURL + 'wx/views/enroll/cmptInfo.html?', 'cId=' + cmptId),
                cmptName + '，点击系统完成在线报名！', cmptName, imgUrl, false);
    },
    hide: function () {
        this.wx('', '', '', '', true);
    }
};
var _nextPage = function (callback, offset, id) {
    if (typeof  offset == "undefined") {
        offset = 0;
    }
    if ($.isUndefined(id)) {
        // id=window;
    } else {
        console.dir($(id).isSee());
        if (!$(id).isSee()) {
            return;
        }
    }
    $(window).scroll(function () {
        //当内容滚动到底部时加载新的内容
        if ($(this).scrollTop() + $(window).height() + offset >= $(document).height() && $(this).scrollTop() > offset) {
            //当前要加载的页码
            callback.call(this);
        }
    });
};
var _delNextPage = function () {
    $(window).unbind('scroll');
};
var _goBack = {
    set: function (id) {
        if (typeof  id == "undefined") {
            id = "comUrl";
        }
        var url = location.href;
        localStorage.setItem(id, url);
    },
    get: function (id) {
        if (typeof  id == "undefined") {
            id = "comUrl";
        }
        var url = localStorage.getItem(id);
        if (null != url) {
            window.location.href = url;
            localStorage.removeItem(id);
        }
    }

};


/** form组件**/
(function ($) {
    $.fn.formToJson = function () {
        var push = function (obj) {
            var strFlag = false;
            var split = ";";
            var name = obj.name;
            var flag = 0;
            if (obj.name.substr(0, "_str".length) == "_str") {
                strFlag = true;//序列化str;
                name = obj.name.substr("_str".length);
                var idx = name.indexOf("_");
                if (idx > 0) {
                    split = name.substring(0, idx);
                }
                name = name.substring(idx + 1);
                var lastIdx = name.lastIndexOf("$");//额外的
                if (lastIdx > 0) {
                    name = name.substring(0, lastIdx);
                }
            }
            if (serializeObj[name]) {
                if ($.isArray(serializeObj[name])) {
                    if (!strFlag) serializeObj[name].push(obj.value.toString().trim());
                    if (strFlag) serializeObj[name] = serializeObj[name] + split + obj.value.toString().trim();
                } else {
                    if (!strFlag) serializeObj[name] = [serializeObj[name], obj.value.toString().trim()];
                    if (strFlag) serializeObj[name] = serializeObj[name] + split + obj.value.toString().trim();
                }
            } else {
                serializeObj[name] = obj.value.toString().trim();
            }
        };
        //开始主
        var serializeObj = {};
        var array = this.serializeArray();

        $(array).each(function () {
            var value = this.value.toString().trim();
            //if ("" != value) {
            push(this);
            //}
        });
        //图片区域(自定义区域)
        //console.dir(this.find("[f-type=image]"));
        this.find("[f-type=image]").each(function (index, elem) {
            var name = $(elem).attr("f-name");
            $(elem).find("img").each(function (index, elem) {
                var value = $(elem).attr("src");
                if (typeof(value) == "undefined") {
                    value = "";
                }
                value = value.trim();
                var obj = {
                    name: name,
                    value: value
                };
                // if ("" != value) {
                push(obj);
                // }
            });
        });
        return serializeObj;
    };

    $.fn.formInitValue = function () {
        var utils = {
            setImageValue: function (elem, val) {
                if (val != "") {
                    var split = ";";
                    split = $(elem).attr("f-split");
                    if (typeof(split) == "undefined") {
                        split = ";";
                    }
                    var vals = val.split(split);
                    $(elem).find("img").each(function (index, element) {
                        if (index < vals.length) {
                            $(element).attr("src", vals[index]).show();
                        }
                    });
                } else {
                    $(elem).find("img").each(function (index, element) {
                        $(element).attr("src", null).hide();
                        var show = $(element).attr("f-show");
                        if ("true" == show) {
                            $(element).attr("src", null).show();
                        }

                    });
                }
            },
            setCityValue: function (elem, name, val) {
                if (val != "") {
                    var split = ";";
                    split = $(elem).attr("f-split");
                    if (typeof(split) == "undefined") {
                        split = ";";
                    }
                    var vals = val.split(split);
                    $(elem).find("select").each(function (index, element) {
                        if (index < vals.length) {
                            console.dir(vals[index]);

                            $(element).val(vals[index]).show();
                            $(element).trigger('change');
                        }
                    });
                } else {
                    $(elem).find("select").each(function (index, element) {
                        $(element).prop("value","");
                        $(element).trigger('change');
                    });
                }
            },
            setCheckboxValue: function (elem, name, val) {
                if (val != "") {
                    var split = ";";
                    split = $(elem).attr("f-split");
                    if (typeof(split) == "undefined") {
                        split = ";";
                    }
                    var vals = val.split(split);
                    for (var i = 0; i < vals.length; i++) {
                        $(elem).find("input[type=checkbox][name='" + name + "'][value='" + vals[i] + "']").prop("checked", true).prev().addClass('laactive');
                    }
                } else {
                    $(elem).find("input[type=checkbox][name='" + name + "']").prop("checked", false).prev().removeClass('laactive');
                }
            },
            setRadioValue: function (elem, name, val) {
                if (val != "") {
                    $(elem).find("input[type=radio][name='" + name + "'][value='" + val + "']").attr("checked", true);
                } else {
                    $(elem).find("input[type=radio][name='" + name + "']").attr("checked", false);
                }
            },
            setSelectValue: function (elem, val) {
                if (val != "") {
                    $(elem).val(val);
                } else {
                    $(elem).val(null);
                }
            }
        };
        var elems = this.find("[f-name]");
        elems.each(function (index, elem) {
            var name = $(elem).attr("f-name");
            var value = $(elem).attr("f-value");
            if (null == _Base.init(value)) {
                value = "";
            }
            var type = $(elem).attr("f-type");
            if ("select" == type) {
                utils.setSelectValue(elem, value);
            }
            if ("checkbox" == type) {
                utils.setCheckboxValue(elem, name, value);
            }
            if ("image" == type) {
                utils.setImageValue(elem, value);
            }//url(文件图片链接等 )
            if ("radio" == type) {
                utils.setSelectValue(elem, name, value);
            }
            if ("city" == type) {
                utils.setCityValue(elem, name, value);
            }

        });
        var idNumInput = function () {
            var IDNumber = $("#IDNumber").val();
            var dateOfBirth = $("#dateOfBirth").val();
            if (null != $.isUndefined(IDNumber) && null != $.isUndefined(dateOfBirth)) {
                $("#IDNumber").on('input', function (e) {
                    var typeOfId = $.Base.init($("#typeOfID").val());
                    dateOfBirth = $.Base.init($("#dateOfBirth").val());
                    if ((null == typeOfId || typeOfId == "身份证")) {
                        var idNumber = e.currentTarget.value;
                        if ("" != idNumber.trim() && (idNumber.length == 18)) {
                            var idBean = _IDNumber.getData(idNumber);
                            console.dir(idBean);
                            $("#dateOfBirth").val(idBean.birthDay);
                        }
                    }
                });
            }
        };
        var initSelectValue = function () {
            //默认
            if (null == _Base.init($("#gender").prop("value")) && $("#gender").attr("data-rule-required") == "true") {
                $("#gender").prop("value", "男");
            }
            if (null == _Base.init($("#typeOfID").prop("value")) && $("#typeOfID").attr("data-rule-required") == "true") {
                $("#typeOfID").prop("value", "身份证");
            }
        };
        initSelectValue();
        idNumInput();
        $(".email").mailAutoComplete();
    };
    $.fn.formCityValue = function () {
        var utils = {
            setCityValue: function (elem, name, val) {
                if (val != "") {
                    var split = ";";
                    split = $(elem).attr("f-split");
                    if (typeof(split) == "undefined") {
                        split = ";";
                    }
                    var vals = val.split(split);
                    $(elem).find("select").each(function (index, element) {
                        if (index < vals.length) {
                            console.dir(vals[index]);

                            $(element).val(vals[index]).show();
                            $(element).trigger('change');
                        }
                    });
                } else {
                    $(elem).find("select").each(function (index, element) {
                        $(element).prop("value","");
                        $(element).trigger('change');
                    });
                }
            }
        };
        var elems = this.find("[f-name]");
        elems.each(function (index, elem) {
            var name = $(elem).attr("f-name");
            var value = $(elem).attr("f-value");
            if (null == _Base.init(value)) {
                value = "";
            }
            var type = $(elem).attr("f-type");
            if ("city" == type) {
                utils.setCityValue(elem, name, value);
            }
        });
    };
})(jQuery);
//form组件
_isPayByOther = {
    checkIsPayByOther: function (bean, callback) {
        $.post(raceURL + "enrollUser/checkIsPayOther.do", {roadId: bean.roadId, userName: bean.userName,
            callPhone: bean.callPhone}, function (data) {
            if (data.result > 0) {
                layer.confirm("已有他人报名该姓名该手机号(他人已经替您报名？),是否继续报名？", function () {
                    callback();
                });
            } else {
                callback();
            }
        });
    }
};
var _formUtil = {
    init: function (id) {
        this.ck_multi_select();
        this.uploadImage();
        this.ck_upload();
        this.loadCitySelect(id);
        this.loadDateUtil(id);
        this.loadDatetimeUtil(id);
        this.initSelectValue(id);
    },
    initSelectValue:function(id){
        $(id).find("select").each(function (index, element) {
            var length=element.options.length;
            var index=0;
            var num=0;
            if(length>0){
                $.each(element.options,function(i,opt){
                    if(null!=_Base.init(opt.value)){
                        num+=1;
                    }
                });
            }
            if(num==1){
                $.each(element.options,function(i,opt){
                    if(null!=_Base.init(opt.value)){
                        $(element).val(opt.value);
                        $(element).trigger('change');
                    }
                });

            }
        });
    },
    clearForm: function (id) {
        $(id).find("[f-name]").attr("f-value", null);
        /*   $(id).find("[f-default]").each(function(i,elem){
         $(elem).attr("f-value",$(elem).attr("f-default"));
         });*/
        $(id).formInitValue();
    },
    ck_upload: function () {
        //触发上传图片
        $('body').on('click', '.uploadpic_form', function () {
            var inputImageForm = $(this).find('input')[0];
            inputImageForm.click();
        });
        $('body').on('click', '.pic_upload', function () {
            var filesInput = $(this).siblings('form').find('input');
            $.each(filesInput, function (index, elem) {
                if (elem.value == '') {
                    $(elem).trigger('click');
                    return false;
                }
            });
        });
    },
    ck_multi_select: function () {
        // 多选按钮
        $('body').on('click', '.multiple_select', function () {
            if ($(this).hasClass('laactive')) {
                $(this).removeClass("laactive");
                $(this).next().prop('checked',false);
            } else {
                $(this).addClass("laactive");
                $(this).next().prop('checked',true);
            }
        });
    },
    //加载城市选择组件
    loadCitySelect: function (id) {
        $(id).find('.city_select').cxSelect({
            url: eventURL + "js/area.json",
            selects: ['group', 'province', 'city'],
            nodata: 'none'
        });
    },
    cityItem: function (data) {
        var value = data;//item.definedValue;
        var item = new Array();
        item[0] = "大陆";
        if (null != value && "" != value.trim()) {
            item[1] = "";
            item[2] = "";
            var itemSplit = value.split("-");
            $(itemSplit).each(function (i, data) {
                item[i] = data;
            });
        }
        return item;
    },
    //处理细项(排除空值)item
    workItem: function (item) {
        var workItem={};
        workItem.hint=function () {
            if (null == _Base.init(item.hint)) {
                return "请输入" + item.name;
            }
            return item.hint;
        };
        item.hint=workItem.hint();
        workItem.itemName=function () {
            if (item.userdefinedId < 1000) {
                return  item.definedColumnName;
            }
            return   "defined_" + item.userdefinedId;
        };
        item.itemName=workItem.itemName();
        workItem.required=function () {
            var require = false;
            if (1 == item.isRequired) {
                require = true;
            }
            return require;
        };
        item.required=workItem.required();
        workItem.optionType=function () {
            var optionTypeVal = _parseInt(item.optionType);
            if (null == optionTypeVal)  optionTypeVal = 0;
            return optionTypeVal;
        };
        item.optionType=workItem.optionType();
        workItem.maxlength=function () {
            var content = item.definedContent;
            var maxlength = _parseInt(item.definedContent);
            if (null == maxlength) {
                switch (workItem.optionType()) {
                    case 1:
                        maxlength = 255;
                        break;
                    case 3:
                        maxlength = 998;
                        break;
                    case 7:
                        maxlength = 5;//最大图片数量
                        break;
                    default:
                        maxlength = 255;
                        break;
                }
            }
            return maxlength;
        };
        item.maxlength=workItem.maxlength();
        workItem.selectList=function () {
            var list=[];
            if(item.optionType==4||item.optionType==6||item.optionType==5){
                if(null!=_Base.init(item.definedContent)){
                    return item.definedContent.toString().trim().split("<br/>");
                }
            }
            return [];
        };
        item.selectList=workItem.selectList();
        return item;
    },
    // 初始化报名项中的日期组件
    loadDateUtil: function (id) {
        $(id).find(".date_util").each(function () {
            var itemId = $(this).attr("id");
            var dateStr = $("#" + itemId).val().trim();
            // 原:2000-01-01 转 2000/01/01
            var myDate = new Date();
            if (dateStr != null && '' != dateStr) {
                myDate = new Date(dateStr.replace(/-/g, "/"));
            }
            var currYear = myDate.getFullYear();
            var currMonth = (parseInt(myDate.getMonth()) + 1) <= 9 ? "0"
                + (parseInt(myDate.getMonth()) + 1)
                : (parseInt(myDate.getMonth()) + 1);
            var currDay = (myDate.getDate() <= 9) ? "0"
                + myDate.getDate() : myDate.getDate();
            if (dateStr != null && '' != dateStr) {
                $("#" + itemId).val(
                        currYear + "-" + currMonth + "-" + currDay);
            }
            var opt = {};
            opt.date = {
                preset: 'date'
            };
            opt.defaultValue = {
                theme: 'android-ics light', // 皮肤样式
                display: 'modal', // 显示方式
                mode: 'scroller', // 日期选择模式
                lang: 'zh',
                endYear: currYear + 2,
                minDate: new Date(1920, 0, 1)
            };
            var optDateTime = $.extend(opt['date'],
                opt['defaultValue']);
            $("#" + itemId).mobiscroll(optDateTime).date(
                optDateTime);
        });
    },
    uploadImage:function(){
        var url = eventURL + "upload/file.do";
        var uploadIndex=0;
        var jqXHR =null;
        $('body').on('click','[name=uploadImg]',function(e){
            jqXHR = $(this).fileupload({
                url: url,
                dataType: 'json',
                add: function (e, data) {
                    var files=data.files;
                    if (files.length > 1) {
                        layer.error('只能上传一张图片');
                        return false;
                    }
                    if (files.length <= 0) {
                        layer.error("请选择上传的图片");
                        return false;
                    }
                    if (files.length == 1) {
                        var picFile = files[0];
                        var fileSize = Math.round(picFile.size / 1024);// kB
                        if (!/(gif|jpg|jpeg|png|GIF|JPG|PNG)$/.test(picFile.type)) {
                            layer.error("图片类型必须是.gif,jpeg,jpg,png中的一种");
                            return false;
                        }
                        if (fileSize > 7*1024) {
                            layer.error("图片必须小于7MB");
                            return false;
                        }

                        var jqXHR =data.submit();
                        uploadIndex=layer.upload("正在上传图片,请等待...",jqXHR);
                    }
                },
                done: function (e, data) {
                    var fileId=$(this).attr("id");
                    if ("success" == data.result.status) {
                        layer.info("图片上传成功...");
                        if (1 == data.result.code) {
                            //单个文件
                            var fileId = fileId.substring("file_".length);
                            var url=ImageDo.init(data.result.result, "");
                            $("#" + fileId).attr("src", url).show();
                        }
                    }
                    if ("fail" == data.result.status) {
                        layer.error("图片上传失败!");
                    }
                },
                fail:function (jqXHR, textStatus) {
                    if (textStatus.textStatus === 'abort') {
                        layer.close(uploadIndex);
                        return;
                    }
                    layer.error("上传图片失败");
                    return false;
                },
                progressall: function (e, data) {
                    var progress = parseInt(data.loaded / data.total * 100, 10);
                    $('#progress .bar').css(
                        'width',
                            progress + '%'
                    );
                    if(progress==100){
                        layer.close(uploadIndex);
                    }
                }
            });
        });
        return jqXHR;
    },
    // 初始化报名项中的时间组件
    loadDatetimeUtil: function (id) {
        $(id).find(".datetime_util")
            .each(
            function () {
                var itemId = $(this).attr("id");
                var dateStr = $("#" + itemId).val().trim();
                // 2000/01/01 00:00
                var myDate = new Date();
                if (dateStr != null && dateStr != '') {
                    myDate = new Date(dateStr.replace(/-/g, "/"));
                }
                var currYear = myDate.getFullYear();
                var currMonth = (parseInt(myDate.getMonth()) + 1) <= 9 ? "0"
                    + (parseInt(myDate.getMonth()) + 1)
                    : (parseInt(myDate.getMonth()) + 1);
                var currDay = (myDate.getDate() <= 9) ? "0"
                    + myDate.getDate() : myDate.getDate();
                var currHours = (myDate.getHours() <= 9) ? "0"
                    + myDate.getHours() : myDate.getHours();
                var currMinutes = (myDate.getMinutes() <= 9) ? "0"
                    + myDate.getMinutes() : myDate.getMinutes();
                if (dateStr != null && dateStr != '') {
                    $("#" + itemId).val(
                            currYear + "-" + currMonth + "-" + currDay
                            + " " + currHours + ":"
                            + currMinutes);
                }
                var opt = {};
                opt.datetime = {
                    preset: 'datetime'
                };
                opt.defaultValue = {
                    theme: 'android-ics light', // 皮肤样式
                    display: 'modal', // 显示方式
                    mode: 'scroller', // 日期选择模式
                    lang: 'zh',
                    // dateFormat: 'yy-mm-dd hh:ii', // 日期格式
                    startYear: currYear - 3, // 开始年份
                    endYear: currYear + 3
                    // 结束年份
                };
                var optDateTime = $.extend(opt['datetime'],
                    opt['defaultValue']);
                $("#" + itemId).mobiscroll(optDateTime).datetime(
                    optDateTime);
            });

    },
    fromRemarkJson: function (bean) {
        bean.IDNumber=bean.idnumber;
        if (null != _Base.init(bean.remark)) {
            var remark = $.evalJSON(bean.remark);
            if (remark.length > 0) {
                $.each(remark, function (i, item) {
                    if (null != _Base.init(item.value)) {
                        bean["defined_" + item.id] = item.value;
                    }
                });
            }
        }
        return bean;
    },
    getEnrollInfo:function(enrollUser,userDefinedList){
        enrollUser.IDNumber=enrollUser.idnumber;
        enrollUser=this.fromRemarkJson(enrollUser);
        $.each(userDefinedList,function(i,item){
            if(item.userdefinedId<1000){
                item.definedValue=enrollUser[item.definedColumnName];
                if(item.userdefinedId==3){
                    item.definedValue="男";
                    if(null!=enrollUser.gender&&enrollUser.gender==1){
                        item.definedValue="女";
                    }
                }
                if(item.userdefinedId==4){
                    item.definedValue=null;
                    if(null!=enrollUser.dateOfBirth){
                        item.definedValue=new Date(enrollUser.dateOfBirth).format("yyyy年MM月dd日")
                    }
                }
            }else{
                if(null!=_Base.init(enrollUser["defined_"+item.userdefinedId])){
                    item.definedValue=enrollUser["defined_"+item.userdefinedId];
                }
            }
        });
        return userDefinedList;
    }
};
// bean
var _Bean = {
    //报名表bean
    enrollUser: {"userMapId": null,
        "callPhone": null, "userName": null, "gender": null, "dateOfBirth": null, "clothingSize": null,
        "shoesSize": null, "typeOfID": null, "email": null, "address": null,
        "contactsName": null, "contactsPhone": null,
        "contactsAddress": null, "contactsRelation": null, "bloodType": null,
        "city": null, "cert": null, "degree": null, "health": null, "remark": null,
        "createTime": null, "noteIsSend": null, "isDelete": 0,
        "cmptId": null, "roadId": null, "teamId": null,
        "updateTime": null, "isPay": null, "registerId": null, "teamSave": null,
        "teamUserId": null, "allPay": null, "serialNumber": null, "note": null,
        "extraPays": null, "idnumber": null, "sumAmount": null
    }
};
var _constant = {
    sms: {
        lot: "恭喜您已中签：{cmptName}-{roadName}。你可访问赛客【个人中心-我的订单】确认中签状态。",
        lotZS: "【{cmptName}】已开通正式报名。进入【个人中心-我的订单】进行正式报名。"
    }
};
/*//百度统计
var _hmt = _hmt || [];
(function () {
    var hm = document.createElement("script");
    hm.src = "//hm.baidu.com/hm.js?dab20de369ad2af5b90a3275ab815890";
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(hm, s);
})();*/


$(function () {
    //防止session失效 10分钟请求一次
    setInterval(function () {
        $.post(eventURL + "registerInfo/session.do", null, function (data) {
            console.dir(data.msg);
        });
    }, 1000 * 60 * 10);
    //判断是否支持html5特性
    if (!$.isHtml5()) {
        alert("您的浏览器版本过低，不支持时髦的Html5的特性，请更换或升级浏览器浏览");
        return;
    }
    $("img[data-src]").lazyload({threshold: 200, data_attribute: "src" });//图片懒加载
});


